package com.ossjk.core.vo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

@ApiModel(description = "返回相应数据")
public class ResponseBean<T> implements Serializable {
	@ApiModelProperty(name = "code",dataType = "Integer",value = "结果代码，1000:成功，1001:失败，1002:异常抛出，1003:未登陆状态，1004:无操作权限，1005:userid可能在别的地方登录,1006:刷新Token")
	private Integer code;
	@ApiModelProperty(name = "msg",dataType = "String",value = "成功失败提示信息")
	private String msg;
	@ApiModelProperty(name = "data",dataType = "Object",value = "数据内容")
	private T data;

	public ResponseBean(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public ResponseBean(Integer code, String msg, T data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	private ResponseBean(Builder<T> builder) {
		this.code = builder.code;
		this.msg = builder.msg;
		this.data = builder.data;
	}

	public static class Builder<T> {
		private Integer code;
		private String msg;
		private T data;

		public Builder<T> code(Integer code) {
			this.code = code;
			return this;
		}

		public Builder msg(String msg) {
			this.msg = msg;
			return this;
		}

		public Builder data(T data) {
			this.data = data;
			return this;
		}

		public ResponseBean build() {
			return new ResponseBean(this);
		}
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
